/**
 */
package de.thwildau.tm.moses.abnf.abnf.impl;

import de.thwildau.tm.moses.abnf.abnf.AbnfPackage;
import de.thwildau.tm.moses.abnf.abnf.Alternation;
import de.thwildau.tm.moses.abnf.abnf.Option;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Option</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.thwildau.tm.moses.abnf.abnf.impl.OptionImpl#getAlternation <em>Alternation</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class OptionImpl extends ElementImpl implements Option
{
  /**
   * The cached value of the '{@link #getAlternation() <em>Alternation</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getAlternation()
   * @generated
   * @ordered
   */
  protected Alternation alternation;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected OptionImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return AbnfPackage.Literals.OPTION;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Alternation getAlternation()
  {
    return alternation;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetAlternation(Alternation newAlternation, NotificationChain msgs)
  {
    Alternation oldAlternation = alternation;
    alternation = newAlternation;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AbnfPackage.OPTION__ALTERNATION, oldAlternation, newAlternation);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setAlternation(Alternation newAlternation)
  {
    if (newAlternation != alternation)
    {
      NotificationChain msgs = null;
      if (alternation != null)
        msgs = ((InternalEObject)alternation).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AbnfPackage.OPTION__ALTERNATION, null, msgs);
      if (newAlternation != null)
        msgs = ((InternalEObject)newAlternation).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AbnfPackage.OPTION__ALTERNATION, null, msgs);
      msgs = basicSetAlternation(newAlternation, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AbnfPackage.OPTION__ALTERNATION, newAlternation, newAlternation));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case AbnfPackage.OPTION__ALTERNATION:
        return basicSetAlternation(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case AbnfPackage.OPTION__ALTERNATION:
        return getAlternation();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case AbnfPackage.OPTION__ALTERNATION:
        setAlternation((Alternation)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case AbnfPackage.OPTION__ALTERNATION:
        setAlternation((Alternation)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case AbnfPackage.OPTION__ALTERNATION:
        return alternation != null;
    }
    return super.eIsSet(featureID);
  }

} //OptionImpl
